import javax.management.MBeanRegistration;
import java.util.ArrayList;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
       /*  Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int L = in.nextInt();
        int R = in.nextInt();
        int count = 0;
        for(int i = L;i <= R;i++){
            int tmp = i;
            while(tmp != 0){
                if(tmp % 10 == 2){
                    count++;
                }
                tmp /= 10;
            }
        }
        System.out.println(count); */

        ArrayList<Integer> nums1 = new ArrayList<>();
        ArrayList<Integer> nums2 = new ArrayList<>();
        nums1.add(1);
        nums1.add(2);
        nums1.add(2);
        nums1.add(2);
        nums2.add(1);
        nums2.add(3);
        nums2.add(2);
        ArrayList<Integer> integers = intersection(nums1,nums2);
        System.out.println(integers.toString());

        /* Scanner in = new Scanner(System.in);
        String str = in.next();
        StringBuilder ret = new StringBuilder(str);
        for (int i = 0; i < ret.length() - 1; i++) {
            if(ret.charAt(i) == ret.charAt(i+1)){
                ret.delete(i,i+2);
                if(i - 2 < 0){
                    i = -1;
                }else {
                    i -= 2;
                }
            }
        }

        if(ret.length() == 0){
            System.out.println(0);
        }else{
            System.out.println(ret.toString());
        } */
    }

    public static ArrayList<Integer> intersection (ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        ArrayList<Integer> ret = new ArrayList<>();
        for (int i = 0; i < nums1.size(); i++) {
            for (int j = 0; j < nums2.size(); j++) {
                if(nums1.get(i) == nums2.get(j) &&
                        !ret.contains(nums1.get(i))){
                    ret.add(nums1.get(i));
                    break;
                }
            }
        }
        return ret;
    }

}
